﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Org.Alexander.Edas
{
    public interface IProtocolFactory
    {
        IProtocol GetProtocol();
    }
    public interface IProtocol
    {
        int InitLength
        {
            get;
            set;
        }
        int HeaderLength
        {
            get;
            set;
        }
        int BodyLength
        {
            get;
            set;
        }
        MemoryStream IOBuffer
        {
            get;
            set;
        }
        MemoryStream Package
        {
            get;
            set;
        }
        byte[] Header
        {
            get;
            set;
        }
        bool DynamicHeader
        {
            get;
            set;
        }
        byte[] HandShakeData
        {
            get;
            set;
        }
        int HandShakeCount
        {
            get;
            set;
        }
        int[] HandShakeLength
        {
            get;
            set;
        }
        bool IsSendReply
        {
            get;
            set;
        }
        bool KeepSending
        {
            get;
            set;
        }

        ProcessStatus Status
        {
            get;
            set;
        }

        void OnGetHeader(Connector connector);
        void OnGetBody(byte[] Package, Connector connector);
        void OnHandShake(Connector connector);
        void OnReplyOk(Connector connector);
        event PackageDataHandler OnPackageReady;
    }
    public enum ProcessStatus
    {
        HandShake,
        HandShakeOk,
        Header,
        Body
    }
}
